//交换机=order.cardrelationid
package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/dataVisualization"
	"github.com/streadway/amqp"
	"strconv"
)

func main() {
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("dataVisualization.log.cardrelationid"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("dataVisualization.queue.cardrelationid"), func(msg amqp.Delivery) {
		relationId,err := strconv.Atoi(string(msg.Body))
		if err != nil {
			return
		}
		rpcDataVisualization := new(dataVisualization.CardPackageOrder).Init()
		defer rpcDataVisualization.Close()
		reply := false
		if err := rpcDataVisualization.CreateOrderInfoByRelationId(context.Background(), &relationId, &reply); err != nil {
			utils.Logerr.Printf("监管可视化-卡包订单任务调用失败，消费记录relationId：%d err:%s\n",relationId,err.Error())
			return
		}
		return
	})
	if err != nil {
		panic(err)
	}
}